package cn.funeralobjects.upms.controller.converter;

import cn.funeralobjects.upms.enums.UserCertificateType;

import java.beans.PropertyEditorSupport;

/**
 * @author FuneralObjects
 * Create date: 2020/6/3 3:43 PM
 */
public class UserCertificateTypePropertyEditor extends PropertyEditorSupport {
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        this.setValue(UserCertificateType.of(text));
    }

    @Override
    public String getAsText() {
        if (getValue() == null) {
            return null;
        }
        UserCertificateType type = (UserCertificateType) getValue();
        return type.getCode();
    }
}
